import Vue from 'vue'
import App from './App.vue'
import store from '../../../store'
import '../../../plugins'
import '../../../utils/permission'
import '@/assets/styles/common.scss'

import BetterScroll from '@/components/better-scroll/index'
// 注册全局组件
Vue.component('BetterScroll', BetterScroll)

//复制到粘贴板插件
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)

// 调试
import Vconsole from 'vconsole'
let vConsole = new Vconsole()
export default vConsole

Vue.config.productionTip = false

if (process.env.NODE_ENV === 'production') {
    window.apiready = () => {
        new Vue({
            store,
            render: h => h(App)
        }).$mount('#app')
    }
} else {
    new Vue({
        store,
        render: h => h(App)
    }).$mount('#app')
}

import {exportBaseUrl, request} from '@/utils/request'
import {getUploadKey} from "@/api/public";

//加载坯布样品详情
export function loadGreySampleDetail(data, callback) {
    return request({
        url: "/grey_sample_pos/list_detail",
        method: "get",
        data,
        isYarn: true
    }, callback);
}

//远程加载图片 暂时不缓存
export function loadPicsFn(that, detail) {
    if(detail.samplePic && detail.samplePic != "") {
        getUploadKey({
            type: "YPSJD"
        }, tokenRes => {
            let samplePicUrl  = exportBaseUrl("res") + "/res/" + detail.samplePic + '?accessToken=' + tokenRes.accessToken;
            detail.firstPic = samplePicUrl;
            detail.pics.push(samplePicUrl);
        });
    }
    if(detail.productPic && detail.productPic != "") {
        getUploadKey({
            type: "YPSJD"
        }, tokenRes => {
            let samplePicUrl  = exportBaseUrl("res") + "/res/" + detail.productPic + '?accessToken=' + tokenRes.accessToken;
            if(detail.firstPic == "") {
                detail.firstPic = samplePicUrl;
            }
            detail.pics.push(samplePicUrl);
        });
    }
}